import React from 'react'
import { Modal, notification } from 'antd'

const warnAudio = new Audio('./alarm.mp3')
const alarmAudio = new Audio('./alarm.mp3')

// 预警
export const warn = (content: string) => {
    warnAudio.currentTime = 0
    warnAudio.play().then()
    notification.warning({
        message: '预警',
        description: content,
        duration: null,
        onClose: () => {
            warnAudio.pause()
        },
    })
}

// 警报
export const alarm = (content: string) => {
    alarmAudio.currentTime = 0
    alarmAudio.play().then()
    Modal.warning({
        title: '报警',
        content,
        centered: true,
        onOk: () => {
            alarmAudio.pause()
        },
    })
}
